<?php

namespace App\Http\Controllers\System;

use App\Common\Result;
use App\Http\Controllers\Controller;
use App\Service\System\RegisterCodeService;
use Illuminate\Http\Request;

class RegisterCodeController extends Controller
{
    public function verifyCode(Request $request)
    {
        $code = $request->input('code');
        $identifyid = $request->input('identifyid');


        if(RegisterCodeService::getRegisterCode($code) || RegisterCodeService::getRegisterCodeId($code,$identifyid))
        {

        }else{
            Result::msg('-111','error','没有此激活码或已被激活');
        }

        if(!RegisterCodeService::updCodeStatus($code,$identifyid)){
            Result::msg('-112','error','激活失败');
        }

        Result::msg('0','success',[]);
    }
	
	public function validCode(Request $request)
    {
        $code = $request->input('code');
        $identifyid = $request->input('identifyid');

        $register_codes = RegisterCodeService::getRegisterCodeId($code,$identifyid);
		
        if($register_codes->is_valid){
            Result::msg('0','success',[]);
        }

        Result::msg('-112','error','授权码失效');
    }
}